package com.ruoyi.xh.controller;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.core.page.TablePageDataInfo;
import com.ruoyi.common.core.domain.CommentResult;
import com.ruoyi.xh.domain.XhOrderDesc;
import com.ruoyi.xh.service.IXhOrderDescService;

/**
 * 订单明细Controller
 *
 * @author songjw
 * @date 2024-12-13
 */
@Api(tags = "订单明细Controller",value = "订单明细Controller")
@RestController
@RequestMapping("/xh/orderDesc")
public class XhOrderDescController extends BaseController {

    @Autowired
    private IXhOrderDescService xhOrderDescService;

    /**
     * 查询订单明细列表
     */
    @PreAuthorize("@ss.hasPermi('xh:orderDesc:list')")
    @GetMapping("/list")
    @ApiOperation("查询订单明细列表")
    public TablePageDataInfo<XhOrderDesc> list(XhOrderDesc xhOrderDesc) {
        return TablePageDataInfo.success(xhOrderDescService.selectXhOrderDescList(xhOrderDesc));
    }

    /**
     * 获取订单明细详细信息
     */
    @PreAuthorize("@ss.hasPermi('xh:orderDesc:query')")
    @GetMapping(value = "/{id}")
    @ApiOperation("获取订单明细详细信息")
    public CommentResult<XhOrderDesc> getInfo(@PathVariable("id") Long id) {
        return CommentResult.success(xhOrderDescService.selectXhOrderDescById(id));
    }

    /**
     * 新增订单明细
     */
    @PreAuthorize("@ss.hasPermi('xh:orderDesc:add')")
    @Log(title = "订单明细", businessType = BusinessType.INSERT)
    @PostMapping
    @ApiOperation("新增订单明细")
    public CommentResult<XhOrderDesc> add(@RequestBody XhOrderDesc xhOrderDesc) {
            xhOrderDescService.insertXhOrderDesc(xhOrderDesc);
        return CommentResult.success();
    }

    /**
     * 修改订单明细
     */
    @PreAuthorize("@ss.hasPermi('xh:orderDesc:edit')")
    @Log(title = "订单明细", businessType = BusinessType.UPDATE)
    @PutMapping
    @ApiOperation("修改订单明细")
    public CommentResult<XhOrderDesc> edit(@RequestBody XhOrderDesc xhOrderDesc) {
            xhOrderDescService.updateXhOrderDesc(xhOrderDesc);
        return CommentResult.success();
    }

    /**
     * 删除订单明细
     */
    @PreAuthorize("@ss.hasPermi('xh:orderDesc:remove')")
    @Log(title = "订单明细", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    @ApiOperation("删除订单明细")
    public CommentResult<XhOrderDesc> remove(@PathVariable Long[] ids) {
            xhOrderDescService.deleteXhOrderDescByIds(ids);
        return CommentResult.success();
    }
}
